package cn.itcast.n3_Java线程;

import lombok.extern.slf4j.Slf4j;

/**
 * @program: juc
 * @description:
 * @author: flyduck
 * @create: 2024-08-29 11:52
 **/
@Slf4j(topic = "c.Test17_interrupt方法_打断正在阻塞的线程_会清除打断标记")
public class Test17_interrupt方法_打断正在阻塞的线程_会清除打断标记 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                log.debug("sleep...");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };

        t1.start();
        Thread.sleep(1000);
        log.debug("interrupt...");
        t1.interrupt();
        log.debug("打断标记:{}", t1.isInterrupted());
    }
}
